package 每日一题;

public class MovingAverage {

    int left,right;
    int sum;
    //next最多调用1000次
    int[] arr=new int[10001];
    int sz;
    /** Initialize your data structure here. */
    public MovingAverage(int size) {
        sz=size;
    }

    public double next(int val) {
        arr[right++]=val;
        sum+=val;
        if(right-left>sz) sum-=arr[left++];
        return sum/(right-left);
    }



}
